//
//  QLMAddBaoxiuBotCell.m
//  Xiaomakuaixiu
//
//  Created by 龚碧容 on 2017/10/14.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "QLMAddBaoxiuBotCell.h"

@implementation QLMAddBaoxiuBotCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)contactBtnAction:(UIButton *)sender {
    [_delegate addAddressBookAction];
}

- (IBAction)hisaddreAction:(UIButton *)sender {
    [_delegate addHisAddressAction];
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *identifiew=@"QLMAddBaoxiuBotCellId";
    QLMAddBaoxiuBotCell *cell=[tableView dequeueReusableCellWithIdentifier:identifiew];
    if (cell==nil) {
        cell=[[[NSBundle mainBundle] loadNibNamed:@"QLMAddBaoxiuBotCell" owner:nil options:nil] firstObject];
        cell.addresDetailTF.font=[UIFont systemFontOfSize:15];
        
        cell.phoneNumTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        cell.truthNameTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        cell.phoneNumTextField.borderStyle = UITextBorderStyleNone;
        cell.truthNameTextField.borderStyle = UITextBorderStyleNone;
        
        CGFloat lheight1 = cell.truthNameTextField.frame.origin.y+cell.truthNameTextField.frame.size.height+10;
CGFloat lheight2 = cell.phoneNumTextField.frame.origin.y+cell.phoneNumTextField.frame.size.height+10;
        CGFloat lheight3 = cell.addresDetailTF.frame.origin.y+cell.addresDetailTF.frame.size.height+5;
        NSArray *hArray=[NSArray arrayWithObjects:@(lheight1),@(lheight2),@(lheight3), nil];
        
        for (int i=0; i<3; i++) {
            
            CGFloat tmpHei=kScreen_width;
            if (i==0) {
                tmpHei=kScreen_width-70;
            }
            
            CGFloat tmpHeight=[hArray[i] floatValue];
            UIView *line1=[[UIView alloc] initWithFrame:CGRectMake(17,tmpHeight-0.5,tmpHei-17,0.5)];
            line1.backgroundColor=[UIColor lightGrayColor];
            [cell addSubview:line1];
        }
        
        NSArray *titlArr=[NSArray arrayWithObjects:@"联系人*",@"联系电话*",@"设备地址*",nil];
        for (int i=0; i<3; i++) {
            CGFloat expOY=0;
            if (i==2) {
                expOY=5;
            }
            UILabel *aTipLabel=[[UILabel alloc] initWithFrame:CGRectMake(20, 10+50*i+expOY, 70, 30)];
            aTipLabel.font=[UIFont systemFontOfSize:15];
            aTipLabel.textColor=[UIColor darkGrayColor];
            NSString *telStr=[NSString stringWithFormat:@"%@",titlArr[i]];
            NSMutableAttributedString *aString=[[NSMutableAttributedString alloc] initWithString:telStr];
            [aString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(telStr.length-1, 1)];
            aTipLabel.attributedText=aString;
            aTipLabel.backgroundColor=[UIColor whiteColor];
            aTipLabel.textAlignment=NSTextAlignmentLeft;
            [cell addSubview:aTipLabel];
        }
        
    }
    return cell;
}

@end
